<?php


namespace Biz\service\advertisement\position;

use Encore\Admin\Grid;
use Encore\Admin\Widgets\Form;
use Exception;

class BizPositionStatSign extends BizPositionPageTpl
{
    const TPL_CONFIG_TPL_NAME = 'statSign查询';

    public function getList(): array
    {
        return [];
    }

    public function getTotal(): int
    {
        return 0;
    }

    public function getGrid(Grid $grid)
    {
        $grid->disableExport();
        $grid->disableRowSelector();
        $grid->disablePagination();
        $grid->disableCreateButton();
        $grid->disableFilter();
        $grid->disableActions();
        $grid->disableDefineEmptyPage();

    }

    public function withInfoHtml(): array
    {
        $condition = $this->getRequestCondition();
        $response = \Doraemon\service\statSign\Basic::getPlatformConfFromDb();
        $conf = var_export($response, true);
        $const = '';
        $constMap = [];
        $sep = "<br/>";
        if ($response) {
            foreach ($response as $module => $v) {
                $constModule = str_replace('-', '_', $module);
                $constModule = strtoupper($constModule);
                if (empty($constMap[$module])) $const .= $sep . "    const MODULE_{$constModule} = '$module';";
                $constMap[$module] = true;
            }
        }
        $const .= $sep . "    const STATIC_CONF = $conf;";
        $logs = [
            "======== CONST 覆盖 \Doraemon\pockets\constInterface\statSign\AutoPlatformModule.php ========",
            "======== 检查类常量定义冲突,提交代码完成配置 ========",
            "<pre>$const</pre>",
        ];

        return $logs ? ["提示", implode("<br/>", $logs)] : [];
    }

    public function getForm(Form $form)
    {

    }

    /**
     * @throws Exception
     */
    public function save($input)
    {
    }

    public function delete($id): int
    {
        return 0;
    }

    public function getFormInfo($id)
    {

    }
}